var UsersList ,OnlineCustom
// formatDate
$(document).ready(function(){
    UsersList = new Vue({
        el:'#customList',
        data:{
            usersList : [],
            chatLog : [],
            userInfo : [],
            customerService : [],
        },
        filters:{
            'formatDate':function (value) {
                console.log(value);
                if(!value) return '';
                let date = new Date(value.toString().length > 10 ? value : value*1000);
                return formatDate(date, 'yyyy-MM-dd hh:mm')
            },

            'jsonParse':function(value,a){
                if(a === 1){
                    return JSON.parse(value).video;
                }else{
                    return JSON.parse(value).thumb;
                }
                
            }
        },
        created: function(){
            var _this = this;
            getUsersList(function(res){
                setPage('pages01' ,res,function(obj ,first) {
                    console.log(obj)
                    _this.usersList = res.slice((obj.index - 1) * obj.limit, obj.index * obj.limit)
                    
                })
                console.log(_this.usersList)
                $("#loading").fadeOut();
            });
        },
        methods: {
            openDialog:function(item){
                var _this = this;
                getChatLog(item.butt_id,item.openid,function(res){
                    _this.chatLog = res['chatlog'];
                    console.log(_this.chatLog);
                    _this.userInfo = item;
                    _this.customerService = res['customerServiceInfo'];
                    layer.open({
                        type: 1,
                        title:'聊天记录',
                        content: $('#dialog'), //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
                        area: ['800px', '500px'],
                        cancel:function(index, layero){
                            $('#dialog').css('display','none');
                        }
                    });
                });
            }
        }
    });
});